package com.icim.xmtm005.dao;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.icim.xmtm005.entity.CtSlimifRetProduct005;

@Repository
public class CtSlimifRetProduct005Dao {
	@Resource
	private JdbcTemplate xmtm005JdbcTemplate;

	public void saveBatch(List<CtSlimifRetProduct005> sheetList) {

		List<Object[]> objsList = new ArrayList<Object[]>();

		for (CtSlimifRetProduct005 sheet : sheetList) {
			objsList.add(new Object[] { sheet.getVendorcode(),
					sheet.getProductname(), sheet.getBoxname(),
					sheet.getShipproduct(), sheet.getProductgrade(),
					sheet.getTrackintime(), sheet.getTrackouttime(),
					sheet.getPosition(), sheet.getDescription(),sheet.getBoxrealid() });
		}
//		StringBuffer sql = new StringBuffer("INSERT INTO CT_SLIMIFRETPRODUCT")
		StringBuffer sql = new StringBuffer("INSERT INTO V_XM_G5_SLIMIFRETPRODUCT_WG")
				.append("(");
		sql.append("VENDORCODE,PRODUCTNAME,BOXNAME,SHIPPRODUCT,PRODUCTGRADE,");
		sql.append("TRACKINTIME,TRACKOUTTIME,POSITION,DESCRIPTION,BOXREALID");
		sql.append(")");
		sql.append("VALUES(?,?,?,?,?,?,?,?,?,?)");

		xmtm005JdbcTemplate.batchUpdate(sql.toString(), objsList);
	}
}
